package com.yuhang.demo.service.impl;

import com.yuhang.demo.exceptionHandler.MyException;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.yuhang.demo.dao.RoleDao;
import com.yuhang.demo.entity.RoleEntity;
import com.yuhang.demo.service.RoleService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

@Service("roleService")
public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements RoleService{


    @Override
    public Integer saveRole(RoleEntity roleEntity) {

        try {
            baseMapper.saveRole(roleEntity);

//            Integer i = null;
//            Integer z = 3;
//            boolean equals = i.equals(z);

            return 1;

        } catch (Exception e) {

            //手动回滚事务
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

            e.printStackTrace();

            throw new MyException(20001,"修改角色信息异常");
        }
    }
}